﻿using System;
using System.Runtime.Serialization;

namespace GurLoader.GlobalHotkey
{
    [Serializable]
    public class HotKeyAlreadyRegisteredException : Exception
    {
        public HotKey HotKey { get; private set; }

        public HotKeyAlreadyRegisteredException(string message, HotKey hotKey) : base(message)
        {
            HotKey = hotKey;
        }

        public HotKeyAlreadyRegisteredException(string message, HotKey hotKey, Exception inner) : base(message, inner)
        {
            HotKey = hotKey;
        }

        protected HotKeyAlreadyRegisteredException( SerializationInfo info, StreamingContext context )
            : base(info, context)
        {
            HotKey = (HotKey) info.GetValue("HotKey", typeof(HotKey));
        }

        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
                throw new ArgumentNullException("info");
         
            info.AddValue("HotKey", this.HotKey);
            base.GetObjectData(info, context);
        }
    }
}